﻿using BCCommon.Enums;
using BCCommon.PaymentEnums;
using BCEntity.Common.SystemFinanceFlowRecord;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BCData.Common.SystemFinanceFlowRecord
{
    /// <summary>
    /// 系统资金流水记录
    /// </summary>
    public interface ISystemFinanceFlowRecordData
    {
        /// <summary>
        /// 追加系统资金流水记录
        /// </summary>
        /// <param name="systemFinanceFlowRecordEntity">系统资金流水记录</param>
        /// <returns></returns>
        Task<SystemFinanceFlowRecordEntity> Append(SystemFinanceFlowRecordEntity systemFinanceFlowRecordEntity);

        /// <summary>
        /// 查询系统资金流水记录
        /// </summary>
        /// <param name="orderNo">订单编号</param>
        /// <param name="userId">用户Id</param>
        /// <param name="flowDirectionType">流水方向</param>
        /// <param name="payChannelType">支付渠道</param>
        /// <param name="flowType">流水类型</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="ascending">升序排序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        Task<(IEnumerable<SystemFinanceFlowRecordEntity>, int)> Query(string orderNo, long? userId, SourceFlowDirectionType? flowDirectionType, PaymentChannelType? payChannelType, FlowType? flowType, DateTime? start, DateTime? end, bool? ascending, int pageIndex = 1, int pageSize = 10);

        /// <summary>
        /// 查询系统资金流水记录
        /// </summary>
        /// <param name="orderNo">订单编号</param>
        /// <param name="userId">用户Id</param>
        /// <param name="flowDirectionType">流水方向</param>
        /// <param name="payChannelType">支付渠道</param>
        /// <param name="flowType">流水类型</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="ascending">升序排序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        Task<(IEnumerable<SystemFinanceFlowRecordExtendEntity>, int)> GetAll(string orderNo, long? userId,
            SourceFlowDirectionType? flowDirectionType, PaymentChannelType? payChannelType, FlowType? flowType, DateTime? start,
            DateTime? end, bool? ascending, int pageIndex = 1, int pageSize = 10);
        /// <summary>
        /// 获取系统资金流水记录
        /// </summary>
        /// <param name="orderNo">订单编号</param>
        /// <param name="flowDirectionType">系统资金流水方向</param>
        /// <returns></returns>
        Task<IEnumerable<SystemFinanceFlowRecordEntity>> GetEntities(string orderNo, SourceFlowDirectionType? flowDirectionType);

        /// <summary>
        /// 获取系统交易流水最后一条记录
        /// </summary>
        /// <returns></returns>
        Task<SystemFinanceFlowRecordEntity> GetLatRecordAsync();
        /// <summary>
        /// 添加系统交易流水
        /// </summary>
        /// <param name="systemFinanceFlowRecordEntity"></param>
        /// <returns></returns>
        Task<SystemFinanceFlowRecordEntity> AppendTran(SystemFinanceFlowRecordEntity systemFinanceFlowRecordEntity);
    }
}